<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" @submit.native.prevent>
      <el-form-item label="关键字" prop="lname">
        <el-input v-model="queryParams.lname" placeholder="请输入银行网点名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table :height="tableHeight" v-loading="loading" :data="bankinfoList" stripe border>
      <el-table-column label="序号" type="index" width="80" align="center"> </el-table-column>
      <el-table-column label="总行编码" prop="clscode" width="200" align="center" />
      <el-table-column label="银行编码" prop="bankcode" width="200" align="center" />
      <el-table-column label="城市编码" prop="citycode" width="200" align="center" />
      <el-table-column label="银行网点名称" prop="lname" class-name="small-padding fixed-width" />
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
import { listBankinfo } from "@/api/basics/bankinfo.js";

export default {
  name: "information",

  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 信息发布列表数据
      bankinfoList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: this.global.pageSize,
        lname: undefined,
      },
    };
  },
  created() {
    this.getList();
  },
  computed: {
    tableHeight() {
      return 'calc(100vh - 250px)'
    }
  },
  methods: {
    /** 获取银行代码列表 */
    getList() {
      this.loading = true;
      listBankinfo(this.queryParams).then((response) => {
        if (response.code == 200) {
          this.bankinfoList = response.data;
          this.total = response.total;
        }
        this.loading = false;
      });
    },

    // 表单重置
    reset() {
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
